import { Repository } from "typeorm";

import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";

import type { Media, MediaGroup } from "qqlx-core";
import { MediaGateway, MediaGroupGateway } from "qqlx-core";
import { MediaSchema, MediaGroupSchema } from "qqlx-cdk";

import { PgDao } from "../../lib/dao.pg.id";

@Injectable()
export class MediaGroupDao extends PgDao<MediaGroup> {
  constructor(
    @InjectRepository(MediaGroupSchema)
    readonly repo: Repository<MediaGroup>,
  ) {
    super({
      repository: repo,
      relations_name: MediaGroupGateway.relations,
    });
  }
}

@Injectable()
export class MediaDao extends PgDao<Media> {
  constructor(
    @InjectRepository(MediaSchema)
    readonly repo: Repository<Media>,
  ) {
    super({
      repository: repo,
      relations_name: MediaGateway.relations,
    });
  }
}
